package com.wangjie.pattern.singleton;

/**
 * 懒汉式
 */
public class Singleton2 {
    private static Singleton2 instance;

    private Singleton2() {

    }

    // 加入同步代码, 解决线程不安全问题
    public synchronized static Singleton2 getInstance() {
        if (instance == null) {
            instance = new Singleton2();
        }

        return instance;
    }
}